import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsxPlugin from "@vitejs/plugin-vue-jsx"
// @ts-ignore
import path from 'path'


/**
 * 基础路径
 */
// @ts-ignore
const projectRootDir = path.resolve(__dirname)

/**
 * 测试地址
 */
const baseUrl = "https://tbox-chenfei-dev.juzhentech.com/TBox.Iot"

/**
 * 正式地址
 */
// const baseUrl = ""

export default defineConfig({
    plugins: [vue(), vueJsxPlugin()],
    resolve: {
        alias: [
            {
                find: '@',
                replacement: path.resolve(projectRootDir, 'src')
            }
        ],
        extensions: ['.js', '.ts', '.tsx', '.jsx', '.json', '.vue', 'scss']
    },
    server: {
        open: true,
        port: 14001,
        proxy: {
            '/api': {
                target: baseUrl,
                changeOrigin: true
            },
            '/local': {
                target: "http://192.168.100.33:5215/",
                changeOrigin: true,
                rewrite: path => path.replace(/^\/local/, '')
            },
            '/map': {
                target: "https://restapi.amap.com/",
                changeOrigin: true,
                rewrite: path => path.replace(/^\/map/, '')
            }
        }
    }
})
